package com.hdoit.kylin.logical.studentManager.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.tennetcn.common.dao.base.impl.SuperService;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.message.SearchModel;
import com.hdoit.kylin.logical.studentManager.dao.IFinalSpeechDao;
import com.hdoit.kylin.logical.studentManager.model.FinalSpeech;
import com.hdoit.kylin.logical.studentManager.service.IFinalSpeechService;
import com.hdoit.kylin.logical.user.service.ITeacherService;
import com.hdoit.kylin.selfcommon.utils.SQLHelper;

/**
 * @author liuli
 * @email
 * @createtime 2017年07月31日 10:21:48
 * @comment
 */
@Component
public class FinalSpeechServiceImpl extends SuperService<FinalSpeech> implements IFinalSpeechService {
	private IFinalSpeechDao finalSpeechDao;
	private ITeacherService teacherService;
	
	public IFinalSpeechDao getFinalSpeechDao() {
		return finalSpeechDao;
	}

	@Resource
	public void setFinalSpeechDao(IFinalSpeechDao finalSpeechDao) {
		this.finalSpeechDao = finalSpeechDao;
	}

	public ITeacherService getTeacherService() {
		return teacherService;
	}

	@Resource
	public void setTeacherService(ITeacherService teacherService) {
		this.teacherService = teacherService;
	}

	@Override
	public int queryCountByGroupId(SearchModel search, String groupId) {
		if(StringUtils.isEmpty(groupId))
			return queryCount(search);
		List<String> teacherIds=teacherService.queryListStringByGroupId(groupId);
		if(null==teacherIds||0>=teacherIds.size())
			return queryCount(search);
		return finalSpeechDao.queryCountByTeacherIds(search, SQLHelper.inClause(teacherIds));
	}

	@Override
	public List<FinalSpeech> queryListByGroupId(SearchModel search,PagerModel pagerModel,String groupId) {
		if(StringUtils.isEmpty(groupId))
			return queryList(search,pagerModel);
		List<String> teacherIds=teacherService.queryListStringByGroupId(groupId);
		if(null==teacherIds||0>=teacherIds.size())
			return queryList(search,pagerModel);
		return finalSpeechDao.queryListByTeacherIds(search, pagerModel, SQLHelper.inClause(teacherIds));
	}
}